package com.august.service.impl;

import com.august.utils.SpringContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

public class OmsTask implements Callable<List<CompanyVo>> {
//    @Autowired
//    private JdbcTemplate jdbcTemplate;

    private int start;
    private int end;
    public OmsTask(int start,int end){
        this.start = start;
        this.end = end;
    }

    @Override
    public List<CompanyVo> call() throws Exception {

        JdbcTemplate mysql1JdbcTemplate = SpringContextUtil.getBean("mysql1JdbcTemplate");


        String sql = "select * from (select rownum rm, PUBHA_ID id_uuid,UUID company_number,PUBHA003 company_name,PUBHA005 company_address " +
        ",PUBHA006 post_code,PUBHA008 corporation,PUBHA009 corporation_tel,PUBHA010 manager,PUBHA011 manager_tel,PUBHA012 contract,PUBHA013 contract_tel" +
        ",PUBHA015 web_url from TB_PUBHA ) where rm between "+start+" and "+end;
        List<Map<String, Object>> mapList = mysql1JdbcTemplate.queryForList(sql);
        return CompanyVo.getCompany(mapList);
    }
}
